﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Twitterizer;


namespace Rsa
{
    class GestorTwitter
    {
        /*CONTA DO TWITTER*/

        //USERNAME: EI_TESTE
        //PASSWORD: EI2101029

       private string consumerKey = "1sMJ4E9E5xWu4Wt8u0LVIw";
       private string consumerSecret = "GQuHLO3jfnHE6tbRokjrGWvCLtk8kpJwre6ZinKaxo";
       private  string callbackUrl = "None";
      /* private string requestTokenUrl = "https://api.twitter.com/oauth/request_token";
       private string AuthorizeUrl = "https://api.twitter.com/oauth/authorize";
       private string AcessTokenUrl = "https://api.twitter.com/oauth/access_token";

       private string AcessToken ="935512681-9mewM9kTmzEHTxQiygseWVZ9H51LkHWnBzShTdKP";
       private string AcessTokenSecret="VTB1Ru9MzdppxWnQyLZQp3jkqEzG5Sq9XFWZqRyTxeU";
       private bool aux;

       private string url = "http://twitter.com/oauth/authorize?oauth_token=[request token]";
        */

        
        string callbackAddy = "oob";
        OAuthTokenResponse tokenResponse2 = new OAuthTokenResponse();




    public void twiter(){


        OAuthTokenResponse tokenResponse = new OAuthTokenResponse();
        tokenResponse = Twitterizer.OAuthUtility.GetRequestToken(consumerKey, consumerSecret, callbackAddy);
        Console.WriteLine("Token is:  " + tokenResponse.Token.ToString());

        string target = "http://twitter.com/oauth/authorize?oauth_token=" + tokenResponse.Token;
        try
        {
            System.Diagnostics.Process.Start(target);
        }
        catch (System.ComponentModel.Win32Exception noBrowser)
        {
            if (noBrowser.ErrorCode == -2147467259)
                Console.WriteLine(noBrowser.Message);
        }
        catch (System.Exception other)
        {
            Console.WriteLine(other.Message);
        }

        string pin = "4773511"; //This WILL NOT WORK. User needs to enter the PIN

       // Enter_PIN enterpin = new Enter_PIN();
       // enterpin.ShowDialog(); //show dialog causes it to wait for user input. Show() would not work

        
        tokenResponse2 = OAuthUtility.GetAccessToken(consumerKey, consumerSecret, tokenResponse.Token, pin);
        Console.WriteLine("App " + tokenResponse2.ScreenName.ToString() + " access allowed.");

    }
        
}

    }        
        
